package com.wyclabs.commons.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * 服务名称
 * @author Wyccc
 * @date 2019/10/10
 */
public interface ServiceName {

    /**
     * 用户服务
     */
    String USER = "wyclabs-user";

    /**
     * 后台管理
     */
    String ADMIN = "wyclabs-admin";

    /**
     * 前台服务
     */
    String WEB = "wyclabs-web";

    @AllArgsConstructor
    enum toEnum {

        WEB("wyclabs-web", "前台服务"),

        ADMIN("wyclabs-admin", "后台管理"),

        USER("wyclabs-user", "用户");

        @Getter
        @Setter
        private String key;

        @Getter
        @Setter
        private String desc;

    }

    static String getDescByKey(String serviceId) {
        toEnum[] toEnums = toEnum.values();
        for (toEnum toEnum : toEnums) {
            if (toEnum.key.equals(serviceId)) {
                return toEnum.desc;
            }
        }
        return null;
    }
}
